
function saveUser(){
    var userName = $("#userName").val();
    if(userName == ""){
        alert("用户名不能为空");
        return;
    }

    var gender = $("input[name='gender']:checked").val();
    if(gender == ""){
        alert("性别不能为空");
        return;
    }
    var birthday = $("#birthday").val();
    if(birthday == ""){
        alert("生日不能为空");
        return;
    }
    var email = $("#email").val();
    if(email == ""){
        alert("邮箱日期不能为空");
        return;
    }
    var phone = $("#phone").val();
    if(phone == ""){
        alert("手机号不能为空");
        return;
    }
    var landline = $("#landline").val();
    if(landline == ""){
        alert("座机号不能为空");
        return;
    }
    var depa = $("#depa").val();
    if(depa == ""){
        alert("部门不能为空");
        return;
    }
	
	var post = $("#post").val();
    if(post == ""){
        alert("人员职务不能为空");
        return;
    }
	
	var organization = $("#organization").val();
    if(organization == ""){
        alert("组织结构不能为空");
        return;
    }
	
	var autograph = $("#autograph").val();
    if(autograph == ""){
        alert("签名不能为空");
        return;
    }
	

    var ajax = new $ax("/user/insert", function (data) {
        // 成功
        if (data.status == "true") {
            alert("添加成功");
            window.location.href='user.html';
        } else {
            alert("添加失败");
        }

    }, function (data) {
        // 失败
        alert("访问失败");
        errorAjax();
        alert("添加失败");
    });

    ajax.setToken(cookie.get("token"));
    ajax.set("userName",userName);
    ajax.set("gender",gender);
    ajax.set("birthday",birthday);
    ajax.set("email",email);
    ajax.set("phone",phone);
    ajax.set("landline",landline);
    ajax.set("depa",depa);
	ajax.set("post",post);
	ajax.set("organization",organization);
	ajax.set("autograph",autograph);
	
    ajax.start();

}

function showDateYYYYmmdd(id) {
    $('#'+id).datetimepicker({
        //language:  'fr',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        showMeridian: 1,
        format: 'yyyy-mm-dd hh:mm',
        language: 'zh'
    });
}
function showDatehhmm(id) {
    $('#'+id).datetimepicker({
        //language:  'fr',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        showMeridian: 1,
        format: 'hh:mm',
        language: 'zh'
    });
}
function onWeekDate(id){
    $('#'+id).datetimepicker({
        //language:  'fr',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        showMeridian: 1,
        format: 'yyyy-mm-dd hh:mm',
        language: 'zh'
    });
}

//return y + '-' + m + '-' + d +' '+h+':'+minute;
function formatDateTimeYMDHM(inputTime) {
    var date = new Date(inputTime);
    var y = date.getFullYear();
    var m = date.getMonth() + 1;
    m = m < 10 ? ('0' + m) : m;
    var d = date.getDate();
    d = d < 10 ? ('0' + d) : d;
    var h = date.getHours();
    h = h < 10 ? ('0' + h) : h;
    var minute = date.getMinutes();
    var second = date.getSeconds();
    minute = minute < 10 ? ('0' + minute) : minute;
    second = second < 10 ? ('0' + second) : second;
    // return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;
    return y + '-' + m + '-' + d +' '+h+':'+minute;
};